package com.mathdroid.gui.main.character;

import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import com.mathdroid.model.Model;

/**
 * This listener unregisters the frame from the model and disposes it.
 */
public final class ItemEnhancementWindowListener implements WindowListener {

	/**
	 * The IModelObserver JFrame.
	 */
	private ItemEnhancementFrame frame = null;
	
	/**
	 * Create a new window listener.
	 * @param f The IModelObserver JFrame.
	 */
	public ItemEnhancementWindowListener(final ItemEnhancementFrame f) {
		this.frame = f;
	}

	@Override
	public void windowActivated(final WindowEvent e) { }

	@Override
	public void windowClosed(final WindowEvent e) { }

	@Override
	public void windowClosing(final WindowEvent e) {
		Model.unregisterObserver(this.frame);
		this.frame.dispose();
	}

	@Override
	public void windowDeactivated(final WindowEvent e) { }

	@Override
	public void windowDeiconified(final WindowEvent e) { }

	@Override
	public void windowIconified(final WindowEvent e) { }

	@Override
	public void windowOpened(final WindowEvent e) { }

}
